﻿@page "/DataSource/MqttTopic"
<PageTitle>MQTT主题配置</PageTitle>
@inherits ComponentBaseDataCenter

<div>
    <h3>MQTT主题配置</h3>
    <Table TItem="MqttTopicVO" UseInjectDataService="false" IsPagination="true" PageItemsSource="PageItems" DoubleClickToEdit="true"
           IsStriped="true" IsBordered="true" ShowSkeleton="true" IsMultipleSelect="true" ShowEmpty="true" ShowLoading="true" ShowColumnList="true"
           ShowToolbar="true" ShowExtendButtons="true"
           ShowSearch="true" ShowAdvancedSearch="false"
           AutoGenerateColumns="false" EditMode="EditMode.Popup"
           OnQueryAsync="QueryAsync" OnSaveAsync="@OnSaveAsync" OnDeleteAsync="OnDeleteAsync" ShowToastAfterSaveOrDeleteModel="false">
        <TableColumns>
            <TableColumn Sortable="true" Filterable="true" Searchable="true" @bind-Field="@context.Name" Width="180" />
            <TableColumn Sortable="true" Filterable="true" Searchable="true" @bind-Field="@context.Topic" />
            <TableColumn Sortable="true" Filterable="true" Searchable="true" @bind-Field="@context.Mqtt.Name" />
            <TableColumn @bind-Field="@context.Mqtt.BrokerAddress" />
            <TableColumn @bind-Field="@context.Mqtt.BrokerPort" />
            <TableColumn Filterable="true" Searchable="true" @bind-Field="@context.Enable" />
        </TableColumns>
        <EditTemplate>
            <div class="row g-3 form-inline">
                <div class="col-12 col-sm-6">
                    <BootstrapInput @bind-Value="@context.Name" placeholder="不可为空，50字以内" maxlength="50" />
                </div>
                <div class="col-12 col-sm-6">
                    <BootstrapInput @bind-Value="@context.Topic" placeholder="不可为空，50字以内" maxlength="50" />
                </div>
                <div class="col-12 col-sm-6">
                    <Select @bind-Value="@context.MqttID" placeholder="不可为空，50字以内" Items="@MqttItems" ShowSearch="true" />
                </div>
                <div class="col-12 col-sm-6">
                    <Switch @bind-Value="@context.Enable" />
                </div>
                @*  <div class="col-12 col-sm-6">
                <BootstrapInput @bind-Value="@context.BrokerAddress" placeholder="请输入服务器IP" maxlength="50" />
                </div>
                <div class="col-12 col-sm-6">
                <BootstrapInput @bind-Value="@context.BrokerPort" placeholder="请输入服务器端口号" />
                </div>
                <div class="col-12 col-sm-6">
                <BootstrapInput @bind-Value="@context.UserName" />
                </div>
                <div class="col-12 col-sm-6">
                <BootstrapInput @bind-Value="@context.Password" />
                </div>*@
            </div>
        </EditTemplate>
        <RowButtonTemplate>
            <TableCellButton Color="Color.Info" Icon="fa-solid fa-pen" Text="测试连接" OnClick="@(()=>OnConnTestAsync(context))" />
            @*<TableCellPopconfirmButton Color="Color.Info" Icon="fa-solid fa-pen" Text="测试" />*@
        </RowButtonTemplate>
        @*<TableColumns>
        <TableColumn @bind-Field="@context.Hobby" Items="GetHobbys(context)" />
        </TableColumns>*@
    </Table>
</div>